package com.tripwego.client.ui.widget;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.tripwego.client.model.EtapeModel;
import com.tripwego.client.ui.pageVoyage.IVoyageView;

public class EtapeWidget extends Composite implements IVoyageView {

	private Presenter presenter;

	private EventBus eventBus;

	private EtapeModel etapeModel;

	/*
	 * Elements graphiques
	 */
	private DisclosurePanel viewPanel = new DisclosurePanel();

	private EtapeHeaderWidget header;

	private EtapeContentWidget content;

	/**
	 * 
	 */
	public EtapeWidget() {
		super();

		header = new EtapeHeaderWidget(this);
		content = new EtapeContentWidget();

		viewPanel.removeStyleDependentName("gwt-DisclosurePanel");
		viewPanel.removeStyleName("gwt-DisclosurePanel");
		viewPanel.setOpen(true);
		viewPanel.setAnimationEnabled(true);

		viewPanel.setHeader(header);
		header.setSize("100%", "1%");
		viewPanel.setContent(content);
		content.setSize("100%", "100%");

		initWidget(viewPanel);
	}

	/**
	 * @return the header
	 */
	public EtapeHeaderWidget getHeader() {
		return header;
	}

	/**
	 * @param header
	 *            the header to set
	 */
	public void setHeader(EtapeHeaderWidget header) {
		this.header = header;
	}

	/**
	 * @return the content
	 */
	public EtapeContentWidget getContent() {
		return content;
	}

	/**
	 * @param content
	 *            the content to set
	 */
	public void setContent(EtapeContentWidget content) {
		this.content = content;
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}

	@Override
	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
	}

	@Override
	public void init() {
		header.setPresenter(presenter);
		header.setEventBus(eventBus);
		header.setEtapeModel(etapeModel);
		header.init();

		content.setPresenter(presenter);
		content.setEventBus(eventBus);
		content.setEtapeModel(etapeModel);
		content.init();
	}

	/**
	 * @return the etapeModel
	 */
	public EtapeModel getEtapeModel() {
		return etapeModel;
	}

	/**
	 * @param etapeModel
	 *            the etapeModel to set
	 */
	public void setEtapeModel(EtapeModel etapeModel) {
		this.etapeModel = etapeModel;
	}

	public boolean isOpen() {
		return viewPanel.isOpen();
	}

	public void open(boolean open) {
		viewPanel.setOpen(open);
	}

}
